package com.faintlight.repository;

import com.faintlight.model.Sentence;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface SentenceRepository extends JpaRepository<Sentence, Long> {
    List<Sentence> findByCollectedBy_Id(Long userId);
    List<Sentence> findBySystemRecommendedTrue();
    long countByCollectedBy_Id(Long userId);

    @Query("SELECT s FROM Sentence s WHERE s.collectedBy.id = :userId ORDER BY s.createdAt DESC")
    List<Sentence> findByCollectedBy_IdOrderByCreatedAtDesc(Long userId);
}
